import service from './require';
 
// 用户是否登录
export function isLogin(){
  return service.get('/appid/login')
}


// 获取登录用户信息
export function getUserInfo(){
  return service.get('/appid/userinfo')
}


// 获取随机字符串
export function getRandomStr() {
  return service.get('/appid/randomstr');
}
 
 
// 更新用户信息
export function verifitySignature(publicKey,signatureMessage ) {
  if(!publicKey.startsWith("0x")){
    publicKey = "0x"+publicKey
  }
  if(!signatureMessage.startsWith("0x")){
    signatureMessage = "0x" + signatureMessage
  }
  var formData = new FormData()
  formData.append("publicKey",publicKey)
  formData.append("signatureMessage",signatureMessage)
  return service.post(`/appid/login`, formData);
}

// 申请域名
export function applyAppIdApi(domainName,signatureMessage ) {
  
  if(!signatureMessage.startsWith("0x")){
    signatureMessage = "0x" + signatureMessage
  }
  var formData = new FormData()
  formData.append("domainName",domainName)
  formData.append("signatureMessage",signatureMessage)
  return service.post(`/appid/apply`, formData);
}

// 退出系统接口
export function quitSysApi(){
  return service.get("/appid/quit")
}

// 获取自己创建的APPID
export function getAppIdListApi(){
  return service.get("/appid/list")
}

// 删除APPID
export function deleteAppIdApi(pkId){
  return service.delete("/appid/delete/"+pkId)
}

